package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：sean
 * @date ：Created in 2022/5/23
 * @description ：订单控制器
 * @version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/order")
public class OrderController {

	@Autowired
	private OrderService orderService;

	// 方法三要素：方法名，参数及返回值
	@PostMapping("/submit")
	public R<String> submit(@RequestBody Orders orders){
		log.info("[订单],orders:{}",orders);
		// 通过订单业务类完成下订单
		orderService.submit(orders);
		return R.success("下单成功");
	}
}
